<?php 
//Luu giu trang thai loc theo loai ho so
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
if(isset($_REQUEST['hdn_recordtype_filter'])){
	$v_recordtype_filter = $_REQUEST['hdn_recordtype_filter'];
} 
//Begin//Xay dung chuoi XML chua gi tri 
$v_list_xml_tag = "";
if(isset($_REQUEST['hdn_list_xml_tag'])){
	$v_list_xml_tag = $_REQUEST['hdn_list_xml_tag'];
}
$v_list_xml_value = "";
if(isset($_REQUEST['hdn_list_xml_value'])){
	$v_list_xml_value = $_REQUEST['hdn_list_xml_value'];
}
$strXML = '<?xml version="1.0" encoding="UTF-8"?><root><data_list>';
for ($i=0;$i<_list_get_len($v_list_xml_tag,_CONST_SUB_LIST_DELIMITOR);$i++){
	$strXML = $strXML ."<"._list_get_at($v_list_xml_tag,$i,_CONST_SUB_LIST_DELIMITOR).">";
	$strXML = $strXML .trim(_replace_XML_bad_char(_list_get_at($v_list_xml_value,$i,_CONST_SUB_LIST_DELIMITOR)));
	$strXML = $strXML ."</"._list_get_at($v_list_xml_tag,$i,_CONST_SUB_LIST_DELIMITOR).">";
}
$strXML = $strXML . "</data_list></root>";
$strXML = str_replace("'","",$strXML);
//End//Lay danh sach cac the XML va gia tri tuong ung voi tung the do
$v_record_id = 0;
if(isset($_REQUEST['hdn_record_id'])){
	$v_record_id = intval($_REQUEST['hdn_record_id']);
}
$v_status = $arr_record_status[0][0];
$v_recordtype = $_SESSION['onegate_current_recordtype'];
$v_receiver = $_SESSION['staff_id'];
//echo htmlspecialchars($strXML) ;exit;
if(_is_sqlserver()){
	
	$license_xml_data_id = _save_XML_to_database('T_TEMP_FILE', 'PK_TEMP_FILE', 'C_TEXT', $strXML);
	//Cap nhat noi dung 
	//echo "<br/>22)".$v_pk_record_work; exit;
		/*$sql = "Exec Onegate_Tax_Content_Update_leav " ;
		$sql = $sql .  $license_xml_data_id ;
		$sql = $sql . "," .  $v_pk_record_work ; */
	//////////////
	$_v100=sizeof($arr_single_record_announce);
	if($_v100==0){
	$sql = "Exec ONEGATE_UPDATE_ANNOUNCE_leav " ;
	$sql = $sql . $v_pk_record_work;
	//echo "<br/>" .$sql;exit;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs_2 = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	}
	///////
	$sql ="Exec SP_CopyText "; 
	$sql=$sql."'T_TEMP_FILE'";
	$sql=$sql.",'C_TEXT','PK_TEMP_FILE',";
	$sql=$sql. $license_xml_data_id;
	$sql=$sql.", 'T_ONEGATE_RECORD_ANNOUNCE'";
	$sql=$sql.",'C_XML_DATA', 'FK_RECORD_WORK',";
	$sql=$sql. $v_pk_record_work;	
	///////////
	//echo "<br/>22)".$sql; exit;
	$ado_conn->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs = $ado_conn->GetRow($sql); 
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));

	

}
sleep(0);
if (!is_null($v_error) && $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_goto_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
?>
<form action="index.php" method="post" name="f_back">
	<input type="hidden" name="fuseaction" value="DISPLAY_SINGLE_NOTIFY_PUNISH_CONTENT">
	<input type="hidden" name="hdn_record_id" value="<?php echo $v_record_id;?>">
	<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter; ?>">
</form>
<Script language="javascript">
	document.forms(0).submit();
</Script>